package com.djinfo.work.service.impl;
import com.djinfo.work.common.bean.AjaxJson;
import com.djinfo.work.common.service.impl.BaseServiceImpl;
import com.djinfo.work.common.util.StringUtil;
import com.djinfo.work.dao.DictHospitalDao;
import com.djinfo.work.dao.impl.DictHospitalDaoImpl;
import com.djinfo.work.entity.QsDictHospital;
import com.djinfo.work.service.DictHospitalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;


/**
 * Created by admin on 2017/7/25.
 */
@Service("DictHospitalService")
public class DictHospitalServiceImpl  extends BaseServiceImpl<QsDictHospital,DictHospitalDaoImpl> implements DictHospitalService {

    @Autowired
    private DictHospitalDao dictHospitalDao;

    @Override
    public AjaxJson getDictHospitalBySearch(String search,int pagenum,int pagesize) {

        AjaxJson ajaxJson=new AjaxJson();
        String hql="";
        if(StringUtil.isEmpty(search)){
            hql=" from QsDictHospital";
        }else {
            hql=" from QsDictHospital where province like '%"+search+ "%' or city like '%"+search+ "%' or hospital like '%"+search+ "%' or dms_code like '%"+search+ "%'";
        }
        List<QsDictHospital> list=dictHospitalDao.page(hql,pagenum,pagesize);

        List<QsDictHospital> list2=dictHospitalDao.getList(hql);

        HashMap map=new HashMap();
        map.put("dictHospitalList",list);
        map.put("total",list2.size());
        ajaxJson.setResult(map);

        return ajaxJson;
    }

    @Override
    public AjaxJson getDictHospitalBySearch2(String search) {
        String hql="";
        hql=" from QsDictHospital where province like '%"+search+ "%' or city like '%"+search+ "%' or hospital like '%"+search+ "%' or dms_code like '%"+search+ "%'";
        List<QsDictHospital> qsDictHospitals=dictHospitalDao.getList(hql);
        AjaxJson ajaxJson=new AjaxJson();
        HashMap map1=new HashMap();
        map1.put("dictHospitalList",qsDictHospitals);
        ajaxJson.setResult(map1);
        return ajaxJson;
    }
}
